# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=akonadi-search
pkgver=22.04.3
pkgrel=0
pkgdesc="Libraries and daemons to implement searching in Akonadi"
# armhf blocked by extra-cmake-modules
# riscv64 blocked by akonadi
# s390x blocked by multiple KDE Frameworks
# ppc64le blocked by qt5-qtwebengine -> akonadi
arch="all !armhf !s390x !riscv64 !ppc64le"
url="https://community.kde.org/KDE_PIM"
license="( GPL-2.0-only OR GPL-3.0-only ) AND ( LGPL-2.1-only OR LGPL-3.0-only )"
depends_dev="
	akonadi-dev>=$pkgver
	akonadi-mime-dev>=$pkgver
	kcalendarcore-dev
	kcmutils-dev
	kconfig-dev
	kcontacts-dev
	kcrash-dev
	kdbusaddons-dev
	ki18n-dev
	kio-dev
	kmime-dev
	krunner-dev
	qt5-qtbase-dev
	samurai
	xapian-core-dev
	"
makedepends="$depends_dev
	extra-cmake-modules
	"
checkdepends="xvfb-run"
source="https://download.kde.org/stable/release-service/$pkgver/src/akonadi-search-$pkgver.tar.xz"
subpackages="$pkgname-dev $pkgname-lang"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	cd build

	# akonadi-sqlite-schedulertest, konadi-sqlite-collectionindexingjobtest,
	# akonadi-mysql-schedulertest and akonadi-mysql-collectionindexingjobtest
	# require running dbus server

	# Prevent the lines using more than 80 characters by looping
	local skipped_tests="("
	local tests="
		akonadi-sqlite-scheduler
		akonadi-sqlite-collectionindexingjob
		akonadi-mysql-scheduler
		akonadi-mysql-collectionindexingjob"
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)test"
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest -E "$skipped_tests"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}
sha512sums="
44715b44d6a972821c02e863dc2e9c6b846abd6da9eb551323ba10b8ef604761d1d24aa60e21bbf89770c3115e1fe5be63782f4deb625e4f67dcce00896c3361  akonadi-search-22.04.3.tar.xz
"
